package com.chuanyekeji.aokai.Controller;

import com.chuanyekeji.aokai.AokaiApplication;
import com.chuanyekeji.aokai.Util.ReturnData;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * 公用页面
 */
@CrossOrigin(origins = "*",maxAge = 3600)
@Controller
public class PublicController {

    @RequestMapping("home")
    String home(){
        return "/admin/home";
    }

    @RequestMapping("information")
    String information() {
        return "/admin/module/information";
    }

    @RequestMapping("informationManager")
    String informationManager() {
        return "/admin/module/informationManager";
    }

    @RequestMapping("addProductManager")
    String product() {
        return "/admin/module/product";
    }

    @RequestMapping("productManager")
    String productManager() {
        return "/admin/module/productManager";
    }

    @RequestMapping("cases")
    String cases() {
        return "/admin/module/cases";
    }

    @RequestMapping("casesManager")
    String casesManager() {
        return "/admin/module/casesManager";
    }

    @RequestMapping("customerMessage")
    String customerMessage() {
        return "/admin/module/customerMessage";
    }

    @RequestMapping("firstPage")
    String firstPage() {
        return "/admin/module/firstPage";
    }

    /**
     * 修改语言
     * @param language
     * @return
     */
    @RequestMapping("changeLanguage")
    @ResponseBody
    String changeLanguage(String language, HttpSession session) {
        AokaiApplication.language.put(session.getId(),language);
        return ReturnData.success("success");
    }
}
